From: mjw@wray-m-3.hpl.hp.com Date: Fri, 24 Sep 2004 14:19:26 +0000 (+0000) Subject: bitkeeper revision 1.1159.1.173 (41542ceeTwqddMwV79qdSnSzhkgg1Q) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~17400^2~578 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=34fe926686b0a1328ac5ed94cd34645fd550c081;p=xen.git bitkeeper revision 1.1159.1.173 (41542ceeTwqddMwV79qdSnSzhkgg1Q) Reorder domain construction so that the domain is created, then the devices are configured and finally the boot image is created. --- diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 6b636be0e5..852f449011 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -499,23 +499,17 @@ class XendDomainInfo: if self.memory is None: raise VmError('missing memory size') + self.init_domain() self.configure_console() self.configure_restart() self.configure_backends() - image = sxp.child_value(config, 'image') - if image is None: - raise VmError('missing image') - image_name = sxp.name(image) - if image_name is None: - raise VmError('missing image name') - image_handler = get_image_handler(image_name) - if image_handler is None: - raise VmError('unknown image type: ' + image_name) - image_handler(self, image) deferred = self.configure() + def cbok(val): + return self.construct_image() def cberr(err): self.destroy() return err + deferred.addCallback(cbok) deferred.addErrback(cberr) except StandardError, ex: # Catch errors, cleanup and re-raise. @@ -523,6 +517,23 @@ class XendDomainInfo: raise return deferred + def construct_image(self): + """Construct the boot image for the domain. + + @return vm + """ + image = sxp.child_value(self.config, 'image') + if image is None: + raise VmError('missing image') + image_name = sxp.name(image) + if image_name is None: + raise VmError('missing image name') + image_handler = get_image_handler(image_name) + if image_handler is None: + raise VmError('unknown image type: ' + image_name) + image_handler(self, image) + return self + def config_devices(self, name): """Get a list of the 'device' nodes of a given type from the config. @@ -741,7 +752,7 @@ class XendDomainInfo: log.debug('init_domain> Created domain=%d name=%s memory=%d', dom, name, memory) self.setdom(dom) - def build_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n): + def build_domain(self, ostype, kernel, ramdisk, cmdline): """Build the domain boot image. """ if self.recreate or self.restore: return @@ -762,26 +773,25 @@ class XendDomainInfo: raise VmError('Building domain failed: type=%s dom=%d err=%d' % (ostype, dom, err)) - def create_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n): + def create_domain(self, ostype, kernel, ramdisk, cmdline): """Create a domain. Builds the image but does not configure it. @param ostype: OS type @param kernel: kernel image @param ramdisk: kernel ramdisk @param cmdline: kernel commandline - @param vifs_n: number of network interfaces """ if not self.recreate: if not os.path.isfile(kernel): raise VmError('Kernel image does not exist: %s' % kernel) if ramdisk and not os.path.isfile(ramdisk): raise VmError('Kernel ramdisk does not exist: %s' % ramdisk) - self.init_domain() + #self.init_domain() if self.console: self.console.registerChannel() else: self.console = xendConsole.console_create(self.dom, console_port=self.console_port) - self.build_domain(ostype, kernel, ramdisk, cmdline, vifs_n) + self.build_domain(ostype, kernel, ramdisk, cmdline) self.image = kernel self.ramdisk = ramdisk self.cmdline = cmdline @@ -1062,8 +1072,7 @@ def vm_image_linux(vm, image): if args: cmdline += " " + args ramdisk = sxp.child_value(image, "ramdisk", '') - vifs = vm.config_devices("vif") - vm.create_domain("linux", kernel, ramdisk, cmdline, len(vifs)) + vm.create_domain("linux", kernel, ramdisk, cmdline) return vm def vm_image_netbsd(vm, image): @@ -1087,8 +1096,7 @@ def vm_image_netbsd(vm, image): if args: cmdline += " " + args ramdisk = sxp.child_value(image, "ramdisk", '') - vifs = vm.config_devices("vif") - vm.create_domain("netbsd", kernel, ramdisk, cmdline, len(vifs)) + vm.create_domain("netbsd", kernel, ramdisk, cmdline) return vm